<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
  <style type="text/css">

/* tooltip */
#tooltip{
  position:absolute;
  border:1px solid #ccc;
  background:#333;
  padding:2px;
  display:none;
  color:#fff;
}
</style>
</head>
<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li class="layui-this" id="aaa">新闻管理</li>
        <li><a href="{:url('admin/news/add')}" class="a_menu">添加新闻</a></li>
      </ul>
    </div> 
    <form class="layui-form serch" action="{:url('admin/news/index')}" method="post">
        <div class="layui-form-item" style="float: left;">
          <div class="layui-input-inline">
            <input type="text" name="title" lay-verify="title" value="{$Think.post.title ?? ''}" autocomplete="off" placeholder="请输入标题" class="layui-input layui-btn-sm">
          </div>
			<div class="layui-input-inline">
            <div class="layui-inline">
                <select name="type" lay-search="">
                  <option value="">分类</option>
                  <option value="1" {notempty name="$Think.post.type"}{if $Think.post.type=='1' }selected{/if}{/notempty}>行业大事件</option>
                  <option value="2" {notempty name="$Think.post.type"}{if $Think.post.type=='2' }selected{/if}{/notempty}>热点新闻</option>
                </select>
            </div>
          </div>
          <button class="layui-btn layui-btn-danger layui-btn-sm" lay-submit="" lay-filter="serch">搜索</button>
        </div>
      </form> 
    <table class="layui-table" lay-size="sm" >
      <colgroup>
        <col width="50">
        <col width="200">
        <col width="200">
        <col width="100">
        <col width="100">
        <col width="100">
        <col width="100">
        <col width="100">
      </colgrou>
      <thead>
        <tr>
          <th>ID</th>
          <th>标题</th>
          <th>副标题</th>
          <th>作者</th>
          <th>类型</th>
          <th>排序</th>
          <th>操作</th>
        </tr> 
      </thead>
      <tbody>
        {volist name="news" id="loop"}
        <tr line_id="{$loop.id}">
          <td>{$loop.id}</td>
          <td>{$loop.title}</td>
          <td>{$loop.subtitle}</td>
          <td>{$loop.author}</td>
		  <td>{if $loop.type=='1'}行业大事件{else}热点新闻{/if}</td>
          <td>{$loop.type_sort}</td>
      
          <td class="operation-menu">
            <div class="layui-btn-group">
              <a href="{:url('admin/news/add',['id'=>$loop.id])}" class="layui-btn layui-btn-xs a_menu layui-btn-primary" id="{$loop.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
              <a class="layui-btn layui-btn-xs layui-btn-primary delete" id="{$loop.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>
            </div>
          </td>
        </tr>
        {/volist}
      </tbody>
    </table>
    <div style="padding:0 20px;">{$news->render()}</div>

    {include file="public/foot"}
    
    <script type="text/javascript">

    $('.delete').click(function(){
      var id = $(this).attr('id');
      layer.confirm('确定要删除?', function(index) {
        $.ajax({
          url:"{:url('admin/news/delete')}",
          data:{id:id},
          success:function(res) {
            // layer.msg(res);
            if(res == 0) {
              // $(this).parent().parent().parent().remove();
              $("tr:[line_id="+id+"]").remove();
              layer.msg("删除成功");

            }else{
              layer.msg("删除失败");
            }
          }
        })
      })
    })
    </script>
  </div>
</body>
</html>
